import win32api
import win32gui
hwnd_title = {}

def get_all_hwnd(hwnd, mouse):
    if (win32gui.IsWindow(hwnd) and
            win32gui.IsWindowEnabled(hwnd) and
            win32gui.IsWindowVisible(hwnd)):
        hwnd_title.update({hwnd: win32gui.GetWindowText(hwnd)})

process_name_array = ['mainWidgetWindow', 'stackedWidgetWindow', '1', '1', '1', '1', '1']

win32gui.EnumWindows(get_all_hwnd, 0)
def getRectangle () :
    for h, t in hwnd_title.items():
        if t :
            print(h, t)
            try:
                index = -1
                index = t.index('FCBrowser');
            except:
                pass
            if index != -1:
                for process_name in process_name_array:
                    h = findChild(h, process_name)
                left, top, right, bottom = win32gui.GetWindowRect(h)
                return [left, top, right, bottom, h]
def findChild(h,chidWord):

    hWndChildList = []
    win32gui.EnumChildWindows(h, lambda hWnd, param: param.append(hWnd), hWndChildList)
    for ch in  hWndChildList:
        title = win32gui.GetWindowText(ch)
        try:
            index = -1
            if not ('1'.__eq__(chidWord)):
                index = title.index(chidWord);
            else:
                index = 0;
        except:
            pass
        if index != -1:
            return ch